package com.system.sysUser.controller;

import com.system.sysUser.pojo.SysUser;
import com.system.sysUser.service.SysUserService;
import com.utils.common.ServerResponse;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
* 描述:
* author: srdl
* date: 2022-01-03
*/

@RestController
@RequestMapping(value="/sysUser")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @GetMapping(value="/list")
    public ServerResponse list(){
        return sysUserService.list();
    }

    @GetMapping(value="/pageList")
    public ServerResponse pageList(PageInfo pageInfo){
        return sysUserService.pageList(pageInfo);
    }

    @GetMapping(value = "/get/{id}")
    public ServerResponse getById(@PathVariable String id){
    return sysUserService.get(id);
    }

    @PostMapping(value = "/add")
    public ServerResponse addSysUser(@RequestBody @Validated SysUser sysUser){
        return sysUserService.addSysUser(sysUser);
    }

    @PutMapping(value = "/delete/{id}")
    public ServerResponse deleteSysUser(@PathVariable String id){
        return sysUserService.deleteSysUser(id);
    }

    @PostMapping(value = "/update")
    public ServerResponse updateSysUser(@RequestBody @Validated SysUser sysUser){
        return sysUserService.updateSysUser(sysUser);
    }

    @PostMapping(value = "/login")
    public ServerResponse login(@RequestBody @Validated SysUser sysUser){
        return sysUserService.login(sysUser);
    }

}
